﻿using Project_Maverick.Content.Images.Background;
using Transformable_Engine_v2.Engine;
using Transformable_Engine_v2.Engine.GameObjects.Containers;
using Transformable_Engine_v2.Engine.GameObjects.Primitives;
using Transformable_Engine_v2.Engine.Graphics;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace Project_Maverick.Screen.Common
{
    public class Background : Container
    {
        public static Background Gray()
        {
            return new Background(new Color(227, 227, 227));
        }
        public static Background Blue()
        {
            return new Background(new Color(81, 187, 255));
        }

        private ImageContainer _triangleLeft, _triangleRight;

        public Background(Color color)
        {
            AddChildren(new RectanglePrimitive
                            {
                                Shape = new TE_Rectangle(0, 0, Game.Options.ScreenSize),
                                FillColor = color,
                            });

            _triangleLeft = new ImageContainer
                                {
                                    Sprite =
                                        SpriteSheetBackground.GetSprite(SpriteSheetBackground.Common.BackgroundTriangles),
                                    Origin = TE_Rectangle.Alignment.TopRight,
                                    Mirror = ImageContainer.MirrorState.MirrorHorizontal,
                                    Color = color,
                                };
            _triangleRight = new ImageContainer
                                 {
                                     Sprite =
                                         SpriteSheetBackground.GetSprite(
                                             SpriteSheetBackground.Common.BackgroundTriangles),
                                     PositionGridBound = new TE_Vector2(48, 0),
                                     Color = color,
                                 };

            AddChildren(_triangleLeft, _triangleRight);
            base.LoadContent();
        }

        public void Exit()
        {
            _triangleLeft.Sprite = SpriteSheetBackground.GetSprite(SpriteSheetBackground.Common.BackgroundAlternateTriangles);
            _triangleRight.Sprite = SpriteSheetBackground.GetSprite(SpriteSheetBackground.Common.BackgroundAlternateTriangles);
        }
    }
}